﻿///******************************************************    
///	FileName:Consultative.js
///	Action: 后台行业资讯管理修改页面JS处理文件
///	Copyright(c)  2004-2008 Sirius Studio
///	Writer:XYF
///	Create Date: 2008-12-30
///	Rewriter:
///	Rewrite Date:
///****************************************************** 
var rightIcon="../../images/websen.gif"
var rightIcons="../../images/icon_nothing.gif";
var txtjbo=new Array("txtTitle","txtKeyWord","txtAuthor","txtOrigin","txtReading","txtClickCount")
//得到焦点
for(var i=0;i<txtjbo.length;i++){ 
    $(txtjbo[i]).onfocus =function (){
        for (var j=0;j<txtjbo.length;j++){
            if (txtjbo[j]==event.srcElement.id){postobj(j);
            }
        }
    }
}

function postobj(num){
    obj = "txt"+num;
    document.getElementById(obj).innerHTML =Business[num];
}

function $(id){
    return document.getElementById(id)
}

function getobj(objName){
    if ($){
        return eval('$("'+ objName +'")');
    }
    else {
        return eval('document.all["'+ objName +'"]');
    }
}
function oo(){
    $("yc").style.display="none";
}

//离开焦点
for(var i=0;i<txtjbo.length;i++){
    $(txtjbo[i]).onblur =function (){
        for (var j=0;j<txtjbo.length;j++){
            if (txtjbo[j]==event.srcElement.id){postobjs(j);
            }
        }
    }
 }
 
function postobjs(num){
    var  obj = "txt"+num;
    var k= getobj(txtjbo[num]).value;
    var k1= getobj(txtjbo[5]).value;
    if (document.getElementById(obj).innerHTML !=""){
        document.getElementById(obj).innerHTML ="";
    }
    if ($(txtjbo[5]).value!=""){  
        if (!isNumber($("txtClickCount").value)) {
            $("txt5").innerHTML =Information[6];
        }
        else {
            $("txt5").innerHTML =""
        } 
    }
}
//提交函数
$("btnServer").onclick=function server(){
    var arr =0;
    if ($(txtjbo[0]).value=="")
    {alert("00");
        document.getElementById("txt0").innerHTML=Information[0];
        arr=1;
    }
    if($("chkChangeDirectionLink").checked){
        if($("text").value==""){
            document.getElementById("link").innerHTML="<font color='ff0000'>转向连接不能为空</font>";
            arr=1; 
        }
        else{
            document.getElementById("txt4").innerHTML+=ok;
        }
       
    }
    else{
       if($("txtReading").value==""){
          document.getElementById("txt4").innerHTML=Information[4];
          arr=1;   
       }
       else
       {
           document.getElementById("txt4").innerHTML=ok;
       }
    }
    if (arr==1)
         return false;
    else
         return true ; 
}

function insert_page(tag,id){   
    var myField; 
    myField = document.getElementById(id); 
    if (document.selection) { 
        myField.focus(); 
        sel = document.selection.createRange(); 
        sel.text = tag; 
        myField.focus(); 
    }else if (myField.selectionStart || myField.selectionStart == '0') { 
        var startPos = myField.selectionStart; 
        var endPos = myField.selectionEnd; 
        var cursorPos = endPos; 
        myField.value = myField.value.substring(0, startPos) 
            + tag 
            + myField.value.substring(endPos, myField.value.length); 
        cursorPos += tag.length; 
        myField.focus(); 
        myField.selectionStart = cursorPos; 
        myField.selectionEnd = cursorPos; 
    }else { 
        myField.value += tag; 
        myField.focus(); 
    } 
}

//转向链接
 function display() { 
    switch($("chkChangeDirectionLink").checked)
    {
        case false:
            $("text").disabled=true;
            $("rowTest1").style.display='block';
            $("rowTests").style.display='block';
            $("text").value="";
            $("link").innerHTML="<font color='ff0000'> 注：请在转向链接前加http://</font>";
            break;
        case true:
            $("text").disabled=false;
            $("rowTest1").style.display='none';
            $("rowTests").style.display='none';
            $("text").value="";
            break;
    }
}
 
//处理信息
var title="<p>";
var titles="</p>"
//显示商业信息修改
var Business=new Array(8)
Business[0]=title+"请输入文章标题"+titles
Business[1]=title+"请输入关键字以便收所到该文章&nbsp;<font color=red>注：每个关键字用逗号隔开</font>"+titles
Business[2]=title+"请输入该的文章作者"+titles
Business[3]=title+"请输入文章来源"+titles
Business[4]=title+"请输入文章备注"+titles
Business[5]=title+"请输入一个点击次数"+titles
var ok="<font color=#999999>输入符合规范</font>";
var Informations="<font color=#FF0000>"
var Informationt="</font>"
var Information=new Array(8)
Information[0]=Informations+"文章标题不能为空，请重新设置文章标题！"+Informationt
Information[1]=Informations+"文章关键字不能为空，请重新设置文章关键字！"+Informationt
Information[2]=Informations+"文章作者不能为空，请重新设置文章作者！"+Informationt
Information[3]=Informations+"文章来源不能为空，请重新设置文章来源！"+Informationt
Information[4]=Informations+"文章备注不能为空，请重新设置文章备注！"+Informationt
Information[5]=Informations+"文章点击数不能为空，请重新设置文章点击数！"+Informationt
Information[6]=Informations+"文章点击数不能为字符，请重新设置文章点击数！"+Informationt
